<template>
  <div>
    <template>
      <el-table :data="tableData" style="width: 100%">
        <el-table-column prop="date" label="日期" width="180">
        </el-table-column>
        <el-table-column prop="name" label="姓名" width="180">
        </el-table-column>
        <el-table-column prop="phone" label="电话"> </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
              >编辑</el-button
            >
            <el-button
              size="mini"
              type="danger"
              @click="handleDelete(scope.$index, scope.row)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </template>
  </div>
</template>

<script>
import json from '../../public/shopList.json'
export default {
  data() {
    return {
      tableData: [
        
      ],
    };
  },
  mounted() {
      console.log(json);
      json.forEach((item)=>{
          let obj = {
              date:new Date().toLocaleString(),
              name:item.name,
              phone:item.phone
          }
          this.tableData.push(obj)
      })
  },
  methods: {
      handleEdit(index, row) {
        console.log(index, row);
      },
      handleDelete(index, row) {
        console.log(index, row);
        this.tableData.forEach((item,i)=>{
            if(index == i){
                this.tableData.splice(i,1)
            }
        })
      }
  },
};
</script>

<style>
</style>